﻿/// <reference path="underscore.js" />
/// <reference path="Student.js" />
(function () {
	var studentsArray = [
		new Student("Kiro", "Skalata", 7, [5, 6, 4, 5]),
		new Student("Ab", "Cto", 20, [6, 6, 6, 5]),
		new Student("Zya", "Ata", 25, [3, 6, 4, 2])
	];

	Array.prototype.Sum = function () {
		var sum = 0;

		for (var i = 0; i < this.length; i++) {
			sum += this[i];
		}

		return sum / this.length;
	}

	function compareNames(students) {
		return _.max(students, function (student) {
			return student.marks.Sum();
		});
	}

	var comparedStudents = compareNames(studentsArray);

	console.log("Student withhighest marks: ");
	console.log(comparedStudents.toString());
})();